package com.ahui.handler.file;


import com.ahui.constant.SupportedFileTypeConst;
import com.ahui.handler.FileHandler;
import com.ahui.handler.FileHandlerFactory;
import com.ahui.util.PdfUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.io.File;
import java.util.List;

@Slf4j
@Component
public class PdfHandler implements FileHandler {


    @Override
    public void afterPropertiesSet() {
        FileHandlerFactory.register(SupportedFileTypeConst.PDF_FILE, this);
    }

    @Override
    public List<String> handleFile(String filePath, String tempFolder) {
        List<String> split = PdfUtil.pdf2img(new File(filePath),tempFolder);
//        AssertUtils.assertTrue(!split.isEmpty(), "PDF切分图片失败！文件信息：{}" + filePath);
        return split;
    }
}
